<template>
	<view class="doctor-wrap">
		<doctor-index v-if="index == 0"></doctor-index>
		<doctor-message v-if="index == 1" ></doctor-message>
		<doctor-member v-if="index == 2"></doctor-member>

		<u-tabbar :current="index" @onChange="tabbarChange"></u-tabbar>
	</view>
</template>

<script>
import {
		userInfo
	} from '@/utils/token.js';
import uTabbar from '@/components/u-tabbar/u-tabbar.vue';
import doctorIndex from '../doctorIndex/doctorIndex.vue';
import doctorMessage from '../doctorMessage/doctorMessage.vue';
import doctorMember from '../doctorMember/doctorMember.vue';
export default {
	components: {
		uTabbar,
		doctorIndex,
		doctorMessage,
		doctorMember
	},
	data() {
		
		return {
			userInfo: null,
			index: 0 // 0首页  1问诊  2我的
		};
	},
	onLoad(option) {
		this.index = option.index ? option.index : 0;
	},
	onShow() {
		this.queryMpInfo();
		this.userInfo = userInfo.get();
	},
	onShareAppMessage(res) {
			if (res.from === 'button') {
				return {
					title: '邀请您一起加入医生平台',
					path: '/pages-mall/qrcodeHandler/qrcodeHandler?scene=doctor_invite&id=' + this.userInfo.id,
					imageUrl: 'https://res.jiuzhang-cloud.com/jzy-oss/upload/image/dti-hospital/ikon@2x.png'
				}
			}
	},
	onReady() {
		this.checkNavigation();
	},
	methods: {
		queryMpInfo() {
			this.$api.getMpConfig().then(res => {
				if (res.code == 200) {
					uni.setNavigationBarTitle({
						title: res.result.contentInfo.plantName //这是修改后的导航栏文字
					})
				}
			})
		},
		tabbarChange(index) {
			this.index = index;
			this.checkNavigation();
		},
		checkNavigation() {
			if (this.index == 0 || this.index == 2) {
				uni.setNavigationBarColor({
					frontColor: '#ffffff',
					backgroundColor: '#6E99C7'
				});
			} else {
				uni.setNavigationBarColor({
					frontColor: '#000000',
					backgroundColor: '#FFFfff'
				});
			}
		}
	}
};
</script>

<style lang="less">
.doctor-wrap {
	padding-bottom: 140rpx;
}
</style>
